#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
    string a;
    cin >> a;

    int n = a.size();
    ll res = 0;
    for (int i = 0; i < (1 << n); i++) {
        int j = i, tmp = 0;
        string x, y;

        while (j) {
            if (j & 1) x += a[tmp];
            else y += a[tmp];

            tmp++;
            j >>= 1;
        }

        sort(x.begin(), x.end(), greater<char>());
        sort(y.begin(), y.end(), greater<char>());

        ll mul = atoi(x.c_str()) * atoi(y.c_str()) * 1ll;
        res = max(res, mul);

    }
    cout << res << endl;
    return 0;
}